<%@ page import="java.util.List" %>
<%--
  Created by IntelliJ IDEA.
  User: 15c
  Date: 2017/6/5
  Time: 18:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title></title>
</head>
<body>
<jsp:include page="head.jsp"/>
<br>
<div style="height: auto;width: 100%;text-align: center">
    <c:forEach items="${studentList}" var="student">
        <div style="float: left;font-weight: bold"><span>学号:</span><span style="color: darkorange">${student.sno}</span>
        </div>
        <div style="float: left;font-weight: bold;margin-left: 2%"><span>姓名:</span><span
                style="color: darkorange">${student.sname}</span></div>
        <div style="float: left;font-weight: bold;margin-left: 2%"><span>总学分:</span><span
                style="color: darkorange">${credit}</span></div>
        <div style="background-color: #3accbd;float: left;font-weight: bold;margin-left: 1%"><a style="color:#fff" href="${pageContext.request.contextPath}/students/add_grade?sno=${student.sno}&sname=${student.sname}">录入成绩</a></div>
        <br>
        <table style="float: left" border="5" cellpadding="4" cellspacing="3" align="center">
            <thead>
            <tr>
                <th>课程号</th>
                <th>课程名</th>
                <th>课程学分</th>
            </tr>
            </thead>
            <c:forEach items="${student.course}" var="course">
                <tr>
                    <td>${course.cno} </td>
                    <td>${course.cname}</td>
                    <td>${course.ccredit}</td>
                </tr>
            </c:forEach>
        </table>
        <table style="float: left" border="5" cellpadding="4" cellspacing="3" align="center">
            <thead>
            <tr>
                <th>成绩</th>
                <th>执行操作</th>
            </tr>
            </thead>
            <c:forEach items="${student.sc}" var="sc">
                <tr>
                    <td>${sc.grade}</td>
                    <td>
                        <div style="float: left;margin-left: 3px;background-color:#ddb413;cursor:pointer;text-align: center"><a
                                href="${pageContext.request.contextPath}/students/update_grade?sno=${sc.sno}&cno=${sc.cno}"
                                style="font-size: 14px;color: #fff">修改成绩</a></div>
                        <div style="float: left;margin-left: 5px;background-color:#1b29dd;cursor:pointer;text-align: center"><a
                                href="${pageContext.request.contextPath}/students/grade_delete?sno=${sc.sno}&cno=${sc.cno}"
                                style="font-size: 14px;color: #fff">删除成绩</a></div>
                    </td>
                </tr>

            </c:forEach>
        </table>
    </c:forEach>
</div>
<script>

    //    成绩更新
    var type = "<%=session.getAttribute("update_grade-type")%>";
    if (type == "ok") {
        (function foo() {
            alert("修改成功");
            <%session.removeAttribute("update_grade-type");%>
        })
        ();
    } else if (type == "error") {
        (function foo() {
            alert("修改失败");
            <%session.removeAttribute("update_grade-type");%>
        })
        ();
    }
    //    成绩添加
    var add_grade_type = "<%=session.getAttribute("add_grade-type")%>";
    if (add_grade_type == "ok") {
        (function foo() {
            alert("添加成功");
            <%session.removeAttribute("add_grade-type");%>
        })
        ();
    } else if (add_grade_type == "error") {
        (function foo() {
            alert("添加失败");
            <%session.removeAttribute("add_grade-type");%>
        })
        ();
    }


    //    成绩删除
    var grade_delete_type = "<%=session.getAttribute("grade_delete-type")%>";
    if (grade_delete_type == "ok") {
        (function foo() {
            alert("删除成功");
            <%session.removeAttribute("grade_delete-type");%>
        })
        ();
    } else if (grade_delete_type == "error") {
        (function foo() {
            alert("删除失败");
            <%session.removeAttribute("grade_delete-type");%>
        })
        ();
    }
</script>
</body>
</html>
